﻿namespace NFakeMail.UnitTests
{
    using System;
    using System.Threading;
    using NUnit.Framework;

    public sealed class FakeMailMessageReceiverTests
    {
        [Test]
        [Description("SHOULD trigger the message received event.")]
        public void ReceiveMessage_T001()
        {
            var autoResetEvent = new AutoResetEvent(false);

            var receiver = new FakeMailMessageReceiver();

            receiver.MessageReceived += (sender, e) => autoResetEvent.Set();

            receiver.ReceiveMessage("127.0.0.1", 1025, "me@me.com", new [] { "you@you.com" }, "message");

            Assert.IsTrue(autoResetEvent.WaitOne(1000));
        }
    }
}
